CC "AdoScript" SET_CWD path:(sADOxxPathGeo) CC "Modeling" GET_ACT_MODEL SETL nCurrentModelID:(modelid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Map center") SETL nMapCenterAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Map longitude") SETL nMapLongAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Map latitude") SETL nMapLatAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Display name") SETL nDisplayNameAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("GeoLocation Data") SETL nGeoLocationDataAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("GeoLocation URL") SETL nGeoLocationURLAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Map width") SETL nMapWidthAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Map height") SETL nMapHeightAttrID:(attrid) CC "Core" GET_ATTR_ID classid:bp-model attrname:("Map URL") SETL nMapURLAttrID:(attrid) CC "Core" GET_ATTR_VAL objid:(nCurrentModelID) attrid:(nMapCenterAttrID) SETL sMapCenterValue:(val) CC "AdoScript" MSGWIN ("Searching for map center location at " + sMapCenterValue) #get tempfilename for longitude and latitude values CC "AdoScript" GET_TEMP_FILENAME SETL sXMLMapCenter:(filename) SYSTEM ("download_coordinates.bat \""+sMapCenterValue+"\" \""+sXMLMapCenter+"\" \"" + g_sProxyServer + "\"") with-console-window CC "AdoScript" FREAD file:(sXMLMapCenter) SETL sMapLocationJSON:(text) CC "AdoScript" MSGWIN hide #user selection which location to use SETL lMapLocations:(replall (replall (replall (sMapLocationJSON, "}]", ""), "[{", ""), "},{", "\n")) # only if more than 1 found IF (tokcnt (lMapLocations, "\n") > 1) { SETL lSelectionField:"" FOR sMapLocation in:(lMapLocations) sep:"\n" { SETL sTempLatString:(copy (sMapLocation, search(sMapLocation, "\"lat\":\"", 0)+7, -1)) SETL sLatString:(copy (sTempLatString, 0, search (sTempLatString, "\"", 0))) SETL sTempLongString:(copy (sMapLocation, search(sMapLocation, "\"lon\":\"", 0)+7, -1)) SETL sLongString:(copy (sTempLongString, 0, search (sTempLongString, "\"", 0))) SETL sTempDisplayNameString:(copy (sMapLocation, search(sMapLocation, "\"display_name\":\"", 0)+16, -1)) SETL sDisplayNameString:(copy (sTempDisplayNameString, 0, search (sTempDisplayNameString, "\"", 0))) SETL lSelectionField:(tokunion (lSelectionField, sDisplayNameString + ";"+ sLongString +";" + sLatString, "\n") } CC "AdoScript" LISTBOX entries:(lSelectionField) toksep:"\n" title:"Search results" oktext:"Ok" boxtext:"Choose the location to be used" IF (endbutton = "ok") { SETL sMapLocationJSON:("\"display_name\":\"" + token (selection, 0, ";") + "\", \"lat\":\"" + token (selection, 2, ";") + "\"lon\":\"" + token (selection, 1, ";") + "\"") } ELSE { EXIT } } ELSE { # if only one, reset the variable to the single one found! SETL sMapLocationJSON:(lMapLocations) } CC "Core" SET_ATTR_VAL objid:(nCurrentModelID) attrid:(nGeoLocationDataAttrID) val:(sMapLocationJSON) SETL sTempLatString:(copy (sMapLocationJSON, search(sMapLocationJSON, "\"lat\":\"", 0)+7, -1)) SETL sLatString:(copy (sTempLatString, 0, search (sTempLatString, "\"", 0))) CC "Core" SET_ATTR_VAL objid:(nCurrentModelID) attrid:(nMapLatAttrID) val:(sLatString) SETL sTempLongString:(copy (sMapLocationJSON, search(sMapLocationJSON, "\"lon\":\"", 0)+7, -1)) SETL sLongString:(copy (sTempLongString, 0, search (sTempLongString, "\"", 0))) CC "Core" SET_ATTR_VAL objid:(nCurrentModelID) attrid:(nMapLongAttrID) val:(sLongString) SETL sTempDisplayNameString:(copy (sMapLocationJSON, search(sMapLocationJSON, "\"display_name\":\"", 0)+16, -1)) SETL sDisplayNameString:(copy (sTempDisplayNameString, 0, search (sTempDisplayNameString, "\"", 0))) CC "Core" SET_ATTR_VAL objid:(nCurrentModelID) attrid:(nDisplayNameAttrID) val:(sDisplayNameString) CC "Core" UPDATE_EXPR_ATTRS modelid:(nCurrentModelID) synchronous:1 CC "AdoScript" INFOBOX ("Your map is centered at " + sDisplayNameString +".\nLongitude: " + sLongString + "\nLatitude: " + sLatString) CC "AdoScript" MSGWIN ("Map is downloaded and constructed at " + sDisplayNameString) CC "AdoScript" GET_TEMP_FILENAME SETL sGeoLocationURL:(filename + ".png") CC "Core" GET_ATTR_VAL objid:(nCurrentModelID) attrid:(nMapURLAttrID) SETL sMapURLValue:(val) SETL sMapFile:(sGeoLocationURL) SYSTEM ("download_map.bat \""+sMapURLValue+"\" \""+sMapFile+"\" \"" +g_sProxyServer+ "\"") with-console-window CC "Core" SET_ATTR_VAL objid:(nCurrentModelID) attrid:(nGeoLocationURLAttrID) val:(sGeoLocationURL) CC "Core" GET_ATTR_VAL objid:(nCurrentModelID) attrid:(nMapHeightAttrID) SETL nMapHeight:(val/ 96 * 2.54cm) CC "Core" GET_ATTR_VAL objid:(nCurrentModelID) attrid:(nMapWidthAttrID) SETL nMapWidth:(val/ 96 * 2.54cm) CC "Modeling" SET_DRAWING_AREA_SIZE w:(nMapWidth) h:(nMapHeight) CC "AdoScript" MSGWIN hide